package com.lgr.store.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.lgr.store.dao.MaterialInputDAO;
import com.lgr.store.utils.ContextUtils;
import com.lgr.store.utils.PageObject;
import com.lgr.store.vo.MaterialInputVo;
import com.lgr.store.vo.MaterialVo;
import com.lgr.store.vo.StorageVo;
import com.lgr.store.vo.SupplierVo;
import javax.annotation.Resource;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MaterialInputService {
    @Resource
    MaterialInputDAO materialInputDAO;

    //查询
    public List<MaterialInputVo> list(MaterialInputVo materialInput, PageObject pager){
        List<MaterialInputVo> materialInputList = materialInputDAO.listAll(materialInput,pager);
        return materialInputList;
    }
    //查询记录数
    public int count(MaterialInputVo materialInput){
        return materialInputDAO.getcount(materialInput);
    }
    //新增
    public void add(MaterialInputVo materialInput){
        materialInputDAO.add(materialInput);
    }
    //删除
    @Transactional
    public void delete(Integer materialInputId){
        materialInputDAO.deleteById(materialInputId);
    }
    //修改
    @Transactional
    public void update(MaterialInputVo materialInput){
        materialInputDAO.update(materialInput);
    }
    //审核
    @Transactional
    public void updateAduit(int aduitStatus,int materialInputId){
    	materialInputDAO.updateAduit(aduitStatus,materialInputId);
    }
    //获取一条数据
    @Transactional
    public MaterialInputVo findById(Integer materialInputId){
        return materialInputDAO.findById(materialInputId);
    }
    //获取一条数据
    @Transactional
    public MaterialInputVo findByOrderId(String batchNo){
        return materialInputDAO.findByOrderId(batchNo);
    }
  //获取一条数据
    @Transactional
    public List<SupplierVo> listSupplier(){
    	return materialInputDAO.listSupplier();
    }
    @Transactional
    public List<StorageVo> listStorage(){
    	return materialInputDAO.listStorage();
    }
    @Transactional
    public MaterialVo findByMaterialCode(String materialCode){
    	return materialInputDAO.findByMaterialCode(materialCode);
    }
    @Transactional
    public SupplierVo findBysupplierCode(String supplierCode){
    	return materialInputDAO.findBysupplierCode(supplierCode);
    }
    //审核
    @Transactional
    public void fuLiaoInStorage(String ids){
        Map<String, String> params = new HashMap<String, String>();
        params.put("itemInType", ContextUtils.ITEMTYPE[0]);
        params.put("idArr", ids);
        materialInputDAO.fuLiaoInStorage(params);
    }
}